<?php
class CiuroomsController extends AppController {

	var $name = 'Ciurooms';
	var $paginate = array(
        'limit' => 12,
        'order' => array(
            'Ciutimetable.id' => 'asc'
             )
        );
	function index() {
		$this->Ciuroom->recursive = 0;
		$this->set('ciurooms', $this->paginate( $this->paginate('Ciuroom',array('Ciuroom.id !='=>1))));// No muestra el salon Pendiente
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid ciuroom', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('ciuroom', $this->Ciuroom->read(null,$id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Ciuroom->create();
			if ($this->Ciuroom->save($this->data)) {
				$this->Session->setFlash(__('The ciuroom has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The ciuroom could not be saved. Please, try again.', true));
			}
		}
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid ciuroom', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Ciuroom->save($this->data)) {
				$this->Session->setFlash(__('The ciuroom has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The ciuroom could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Ciuroom->read(null, $id);
		}
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for ciuroom', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Ciuroom->delete($id)) {
			$this->Session->setFlash(__('Ciuroom deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Ciuroom was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
